package com.bw.hongye.user.controller;


import com.aliyun.common.utils.PageUtils;
import com.aliyun.common.utils.R;
import com.bw.hongye.user.entity.BrokerEntity;
import com.bw.hongye.user.service.BrokerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;




/**
 * 
 *
 * @author tZhe
 * @email tZhe@hongye.com
 * @date 2021-07-16 21:12:28
 */
@RestController
@RequestMapping("user/broker")
public class BrokerController {
    @Autowired
    private BrokerService brokerService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = brokerService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{brokerId}")
    public R info(@PathVariable("brokerId") Long brokerId){
		BrokerEntity broker = brokerService.getById(brokerId);

        return R.ok().put("broker", broker);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody BrokerEntity broker){
		brokerService.save(broker);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody BrokerEntity broker){
		brokerService.updateById(broker);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] brokerIds){
		brokerService.removeByIds(Arrays.asList(brokerIds));

        return R.ok();
    }

}
